const Router = require("koa-router");
const auth = require("../middleware/auth");
const {
    Login,
    Register,
    Detail,
    Update,
    Follow,
    FollowUser,
    UnFollowUser,
    Followers,
    FollowTopic,
    UnFollowTopic,
    FollowingTopics,
} = require("../controller/user");

const user = new Router();

// 用户登录
user.post("/login", Login);
// 用户注册
user.post("/register", Register);
// 获取用户信息
user.get("/:id", auth, Detail);
// 更新用户信息
user.patch("/:id", auth, Update);
// 用户关注列表
user.get("/:id/following", auth, Follow);
// 用户粉丝列表
user.get("/:id/followers", Followers);
// 关注
user.put("/following/:id", auth, FollowUser);
// 取消关注
user.delete("/following/:id", auth, UnFollowUser);

// 关注话题
user.put("/followingtopics/:id", auth, FollowTopic);
// 取消关注话题
user.delete("/followingtopics/:id", auth, UnFollowTopic);
// 用户关注话题列表
user.get("/:id/followingtopics", FollowingTopics);

module.exports = user;
